package com.platform.helper.bean;

import ma.glasnost.orika.MapperFacade;
import ma.glasnost.orika.MapperFactory;
import ma.glasnost.orika.impl.DefaultMapperFactory;

/**
 * describe:Mapper工具类
 * Orika工具
 * @author rainly
 * @date 2020/4/17
 * @time 4:39 下午
 */
public class MapperUtil {

    /**
     * 默认字段工厂
     */
    private static final MapperFactory MAPPER_FACTORY = new DefaultMapperFactory.Builder().build();

    /**
     * 默认字段实例
     */
    private static final MapperFacade MAPPER_FACADE = MAPPER_FACTORY.getMapperFacade();

    /**
     * Map对象转 Bean对象
     * @param data map对象
     * @param toClass Bean对象
     * @param <E>
     * @param <T>
     * @return
     */
    public static  <E, T> E map(T data,Class<E> toClass) {
        return MAPPER_FACADE.map(data, toClass);
    }
}
